package com.nogroup.springbootproject.controller;

import com.nogroup.springbootproject.service.DataCountService;
import com.nogroup.springbootproject.utils.result.DataResult;
import com.nogroup.springbootproject.vo.DataCountVo;
import com.nogroup.springbootproject.vo.EchartsPieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("data")
public class DataCountController {

    @Resource
    private DataCountService dataCountService;

    @RequestMapping("getMainData")
    public DataResult getMainData(){
        DataCountVo mainData = dataCountService.getMainData();
        return DataResult.successByData(mainData);
    }

    @RequestMapping("getClassApplyCountForPie")
    public DataResult getClassApplyCountForPie(){
        List<EchartsPieVo> echartsPieVoList = dataCountService.getClassApplyCountForPie();
        echartsPieVoList.forEach(echartsPieVo -> {
                System.out.println("Name:" + echartsPieVo.getName());
                System.out.println("Value:" + echartsPieVo.getValue());
        });
        return DataResult.successByDataArray(echartsPieVoList);
    }

}
